<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <base href="${request.contextPath}/"/>
    <meta charset="UTF-8">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,minimum-scale=1.0">
    <title>漠河智慧社区</title>
    <link href="Content/wechat/css/reset.css" rel="stylesheet" type="text/css">
    <!--  <link href="css/index.css" rel="stylesheet" type="text/css">-->
    <link href="Content/wechat/css/woDeWangGe.css" rel="stylesheet" type="text/css">
    <link href="Content/wechat/css/woDeXinYuan_FB.css" rel="stylesheet" type="text/css">
    <script src="Content/wechat/js/jquery.min.js"></script>
    <!--字体缩放-->
    <script src="Content/wechat/js/ziti.js"></script>
    <!--end 字体缩放-->
    <!--页码js-->
    <script src="Content/wechat/js/myPagination.js"></script>
    <!--页码-->
    <link href="Content/wechat/css/myPagination.css" rel="stylesheet" type="text/css">
</head>
<body>
<header>
    <img src="Content/wechat/images/wdwg.jpg">
</header>
<div class="xinyuan">
    <div class="xinyuan_box">

        <dl class="clearfix">
            <dt>所在小区</dt>
            <dd><select name="villageid" id="villageid" onchange="villageChange(this.value)">
                <option>---请选择---</option>
            </select>
            </dd>
        </dl>
        <dl class="clearfix">
            <dt>楼栋号</dt>
            <dd><select name="buildingnumid" id="buildingnumid">
                <option>---请选择---</option>
            </select>
            </dd>
        </dl>

        <div class="sousuo" onclick="btnSelect()">搜索</div>
    </div>
</div>

<div class="dianLiang_list" id="dianLiang_list" style="display: none">
    <!--    <div class="dianLiang_list_box">-->
    <!--        <h4>所属社区：<span>西郊社区</span></h4>-->
    <!--        <h4>所属网格：<span>西郊社区</span></h4>-->
    <!--        <h4>网格长：<span>王晰</span></h4>-->
    <!--        <h4>电话：<span>139-5689-8653</span></h4>-->
    <!--    </div>-->
</div>


</body>
<script>
    var villageList =${village!};
    var buildingnumList =${buildingnum!};
    $.each(villageList, function (index, items) {
        $("#villageid").append("<option value='" + items.id + "'>" + items.text + "</option>");
    });

    function villageChange(villageId) {

        $("#buildingnumid").empty();
        $("#buildingnumid").append("<option value=\"0\">---请选择---</option>");
        $.each(buildingnumList, function (index, items) {
            if (items.parentId == villageId) {
                $("#buildingnumid").append("<option value='" + items.id + "'>" + items.text + "</option>");
            }
        });

    }

    var isSummit = true;

    function btnSelect() {
        if ($("#buildingnumid").val() == 0) {
            alert("请选择楼栋号");
            return false;
        }
        if (!isSummit) {
            alert("正在查询，请稍后");
        } else if (isSummit) {
            isSummit = false;
            $.ajax({
                //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "/wechat/home/gridding/GetEntity",//url
                data: {buildingnumid: $("#buildingnumid").val()},
                success: function (result) {
                    console.log(result);//打印服务端返回的数据(调试用)
                    var json = JSON.parse(result.data);
                    if (result.code == 200 && json.total > 0) {
                        $("#dianLiang_list").show();
                        $("#dianLiang_list").html(" <div class=\"dianLiang_list_box\">\n" +
                            "            <h4>所属社区：<span>" + json.rows[0].communityname + "</span></h4>\n" +
                            "            <h4>所属网格：<span>" + json.rows[0].gridding + "</span></h4>\n" +
                            "            <h4>网格长：<span>" + json.rows[0].griddingname + "</span></h4>\n" +
                            "            <h4>电话：<span>" + json.rows[0].griddingphone + "</span></h4>\n" +
                            "        </div>");
                        isSummit = true;
                    } else {
                        isSummit = true;
                        alert("暂无数据");
                        $("#dianLiang_list").html("");
                    }
                },
                error: function () {
                    alert("异常！");
                    isSummit = true;
                }
            });
        }
    }


</script>
</html>